home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS26.ADF / SoundScape / AztecExamples / chord.c < prev    next >
C/C++ Source or Header  |  1989-01-26  |  2KB  |  117 lines

  1. #include "exec/types.h"
  2. #include "exec/exec.h"
  3. #include "intuition/intuition.h"
  4. #include "soundscape.h"
  5.  
  6. /*    First, the data for the icon in the Patch Panel  */
  7.  
  8. UWORD chorddata[] = {
  9. 0,    0,    
  10. 0,    0,    
  11. 0,    0,    
  12. 0,    0,    
  13. 0,    0,    
  14. 6,    0,    
  15. 1,    32768,    
  16. 255,    57344,    
  17. 1,    32768,    
  18. 6,    0,    
  19. 0,    0,    
  20. 0,    0,    
  21. 0,    0,    
  22. 0,    0,    
  23. 0,    0,    
  24. 0,    0,    
  25. 0,    96,    
  26. 0,    96,    
  27. 3072,    96,    
  28. 3072,    992,    
  29. 3072,    992,    
  30. 3072,    96,    
  31. 3072,    96,    
  32. 31744,    992,    
  33. 31744,    992,    
  34. 0,    96,    
  35. 0,    96,    
  36. 0,    992,    
  37. 0,    992,    
  38. 0,    0,    
  39. 0,    0,    
  40. 0,    0,    
  41. };
  42.  
  43. struct Image chordimage = { 0,0,32,16,2,chorddata,3,0,0 };
  44.  
  45. /*    This module has a port id. */
  46.  
  47. unsigned short thisport;
  48.  
  49. opencode(direction)
  50.  
  51. /*    Always happy to open. */
  52.  
  53. unsigned char direction;
  54.  
  55. {
  56.     return(1);
  57. }
  58.  
  59. closecode(direction)
  60.  
  61. unsigned char direction;
  62.  
  63. {
  64.     return(1);
  65. }
  66.  
  67. outcode(event)
  68.  
  69. /*    Strip the channel information from the status byte.  If
  70.     this is a NOTEON or NOTEOFF event, create two new events,
  71.     copy the status and velocity into them, add constants to
  72.     their note values, and ship off all three.   Otherwise, 
  73.     free this event.
  74. */
  75.  
  76. struct Note *event;
  77.  
  78. {
  79.     struct Note *secondevent;
  80.     unsigned char status;
  81.     enteraztec();
  82.     status = event->status & 0xF0;
  83.     if ((status == NOTEON) || (status == NOTEOFF)) {
  84.     secondevent = (struct Note *) AllocNode(NOTE);
  85.     if (secondevent) {
  86.         secondevent->status = event->status;
  87.         secondevent->velocity = event->velocity;
  88.         secondevent->value = event->value + 4;
  89.         Send(thisport,secondevent);
  90.     }
  91.     secondevent = (struct Note *) AllocNode(NOTE);
  92.     if (secondevent) {
  93.         secondevent->status = event->status;
  94.         secondevent->velocity = event->velocity;
  95.         secondevent->value = event->value + 7;
  96.         Send(thisport,secondevent);
  97.     }
  98.         Send(thisport,event);
  99.     }
  100.     else FreeNode(event);
  101.     leaveaztec();
  102. }
  103.  
  104. long SoundScapeBase;
  105.  
  106. main() {
  107.     SoundScapeBase = OpenLibrary("soundscape.library",0);
  108.     if (SoundScapeBase) {
  109.     CloseLibrary(SoundScapeBase);
  110.     thisport = AddMidiPort(opencode,closecode,0,outcode,&chordimage,
  111.         &chordimage,-1,"chord maker");    
  112.     SetTaskPri(FindTask(0),-20);
  113.     while (MidiPort(thisport)) Delay(100);
  114.     }
  115. }
  116.  
  117.